package com.bedrock.project.inside.api.v1;

import java.util.List;

import com.bedrock.framework.security.LoginUser;
import com.bedrock.framework.security.service.TokenService;
import com.bedrock.project.enums.ResCode;
import com.bedrock.project.inside.entity.Interviewer;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.bedrock.framework.aspectj.lang.annotation.Log;
import com.bedrock.framework.aspectj.lang.enums.BusinessType;
import com.bedrock.project.inside.service.IInterviewerService;
import com.bedrock.framework.web.controller.BaseController;
import com.bedrock.framework.web.domain.AjaxResult;
import com.bedrock.common.utils.poi.ExcelUtil;
import com.bedrock.framework.web.page.TableDataInfo;

import javax.servlet.http.HttpServletRequest;

/**
 * 面试官池Controller
 * 
 * @author bedrock
 * @date 2020-04-08
 */
@RestController
@RequestMapping("/inside/interview")
public class InterviewerController extends BaseController
{
    @Autowired
    private IInterviewerService interviewerService;

    @Autowired
    private TokenService tokenService;

    /**
     * 查询面试官池列表 @PreAuthorize("@ss.hasPermi('inside:interview:list')")
     */
    @ApiOperation("面试官列表 -- wengus")
    @ApiImplicitParams({
            @ApiImplicitParam(name="technologyId",value="技术类型",dataType="int", required = false ,paramType = "query",example="12"),
            @ApiImplicitParam(name="viewStatic",value="面试官状态",dataType="int",  required = false ,paramType = "query",example="1")})
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) Integer technologyId,
                              @RequestParam(required = false) Integer viewStatic)
    {

        Interviewer interviewer = new Interviewer();
        if(technologyId!=null){
            interviewer.setTechnologyId(technologyId);
        }
        if(viewStatic!=null){
            interviewer.setViewStatic(viewStatic);
        }
        startPage();
        List<Interviewer> list = interviewerService.selectInterviewerList(interviewer);
        return getDataTable(list);
    }

    /**
     * 新增面试官池 @PreAuthorize("@ss.hasPermi('inside:interview:add')")
     */
    @ApiOperation("新增面试官 -- wengus")
    @ApiImplicitParams({
            @ApiImplicitParam(name="userIds",value="用户Ids",dataType="List", required = true,paramType = "List",example="12")})
    @Log(title = "新增面试官", businessType = BusinessType.INSERT)
    @GetMapping("/add/{userIds}")
    public AjaxResult add(@PathVariable List<Long> userIds,HttpServletRequest request)
    {
        LoginUser loginUser = tokenService.getLoginUser(request);
        String result = interviewerService.insertInterviewerList(userIds,loginUser.getUser().getUserId());
        return new AjaxResult(ResCode.$200.getCode(),result);

    }

//    /**
//     * 修改面试官池 @PreAuthorize("@ss.hasPermi('inside:interview:edit')")
//     */
//    @Log(title = "面试官池", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody Interviewer interviewer)
//    {
//        return toAjax(interviewerService.updateInterviewer(interviewer));
//    }

    /**
     * 删除面试官池 @PreAuthorize("@ss.hasPermi('inside:interview:remove')")
     */
    @ApiOperation("删除面试官 -- wengus")
    @ApiImplicitParams({
            @ApiImplicitParam(name="ids",value="面试官池数据List",dataType="object", required = true ,paramType = "path",example="12,14,16")})
    @Log(title = "删除面试官", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(interviewerService.deleteInterviewerByIds(ids));
    }





}
